package com.eso.haBank.domain
/**
 * 系统模块Domain类
 */

import groovy.transform.EqualsAndHashCode
import groovy.transform.ToString

@EqualsAndHashCode
@ToString(includeNames = true, includeFields = false, excludes = 'metaClass,beforeInsert,beforeUpdate')
class SystemModule implements Serializable {

    long id;
    String moduleName;//模块名称
    long moduleSort;//排序
    Integer moduleStatus;//状态

    String comment;//描述

    String obligateField1;//预留字段1
    String obligateField2;//预留字段2
    String obligateField3;//预留字段3

    String createUser;
    Date createTime;
    String updateUser;
    Date updateTime;

    static hasMany = [menus : SystemMenu]

    static constraints = {
        moduleName(blank: false, maxSize: 100, unique: true)
        moduleSort()
        moduleStatus(inList: [1, 0])

        comment(nullable: true, maxSize: 200)

        obligateField1(nullable: true, maxSize: 500)
        obligateField2(nullable: true, maxSize: 500)
        obligateField3(nullable: true, maxSize: 500)

        createUser(blank: false, maxSize: 10)
        createTime(nullable: true)
        updateUser(blank: false, maxSize: 10)
        updateTime(nullable: true)
    }

    def beforeInsert = {
        createTime = new Date()
        updateTime = new Date()
    }

    def beforeUpdate = {
        updateTime = new Date()
    }

    static mapping = {
        table 'sys_module'
        version false
        menus joinTable: [name:'sys_module_and_menu', column: 'menu_id', key: 'module_id']
    }
}
